/*
 * Created by SharpDevelop.
 * User: dvetters
 * Date: 7/28/2010
 * Time: 9:38 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace Echium2
{
	/// <summary>
	/// Description of MediaList.
	/// </summary>
	public partial class MediaList : ListView
	{
		public MediaList()
		{
			InitializeComponent();
		}
		
		public MediaListItem AddItem(EchiumTrack song)
		{
			TimeSpan duration = TimeSpan.FromMilliseconds(song.Duration);
        	string time = ((duration.Hours > 0)?duration.Hours + ":":"") + ((duration.Minutes > 9)?""+duration.Minutes:((duration.Hours > 0)?"0":"")+duration.Minutes) + ":" + ((duration.Seconds > 9)?""+duration.Seconds:"0"+duration.Seconds);
        	MediaListItem item = new MediaListItem(new string[] { song.Title, (string.IsNullOrEmpty(song.Artist)) ? "" : song.Artist, (string.IsNullOrEmpty(song.Album)) ? "" : song.Album , time}, song);
        	return (MediaListItem)this.Items.Add((ListViewItem)item);
		}
		
		public MediaListItem AddItem(string Title, string Artist, string Album,
		                             string Location, int id, long Time)
		{
			EchiumTrack song = MediaGlobals.MainLibrary.NewTrack(Title, Location, Time);
			song.Album = Album;
			song.Artist = Artist;
			return this.AddItem(song);
		}
	}
}
